package com.my.study.jdbc.service.impl;

import com.my.study.jdbc.dao.BookDao;
import com.my.study.jdbc.entity.BookEntity;
import com.my.study.jdbc.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Carlos
 * @version 1.0
 * @Description TODO
 * @date 2021/11/7 12:31
 **/
@Service
public class BookServiceImpl implements BookService {

    @Autowired
    private BookDao bookDao;

    @Override
    public int update(BookEntity book) {
        return bookDao.update(book);
    }

    @Override
    @Transactional(value = "transactionManagerTwo", rollbackFor = Exception.class)
    public void multiUpdate(BookEntity bookOne, BookEntity bookTwo) {
        bookDao.update(bookOne);

        int i = 1 / 0;

        bookDao.update(bookTwo);
    }
}
